<?php
namespace App\Services\TencentIm;


class ChatServices extends BaseConfig {

    /**
     * Describe:管理员向某个人发送消息/或者管理员已某个用户的身份发送消息给某人
     * User: TANGFEN
     * DateTime: 2022/3/1 14:15
     */
    public function sendmsg($messages,$userId){

        $url = $this->url.'openim/sendmsg';
        $data = [
            'To_Account'=>$userId,
            'MsgRandom'=>$this->random, //随机数
            'MsgBody'=>[
                [
                    'MsgType' =>'TIMTextElem',
                    'MsgContent' =>[
                        'Text'=>$messages
                     ],
                ]
            ]
        ];
        return  $this->common($url,$data);
    }

    /**
     * Describe:批量发送消息给指定用户
     * User: TANGFEN
     * $messages 消息内容
     * $userIds 用户id [32,43]
     * DateTime: 2022/3/1 14:54
     */
    public function batchsendmsg($messages,$userIds){

        $url = $this->url.'openim/batchsendmsg';
        $data = [
            'To_Account'=>$userIds,
            'MsgRandom'=>$this->random, //随机数
            'MsgBody'=>[
                [
                    'MsgType' =>'TIMTextElem',
                    'MsgContent' =>[
                        'Text'=>$messages
                    ],
                ]
            ]
        ];
        return  $this->common($url,$data);
    }

}